home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HyperLib 1997 Winter - Disc 1
/
HYPERLIB-1997-Winter-CD1.ISO.7z
/
HYPERLIB-1997-Winter-CD1.ISO
/
オンラインウェア
/
BUS
/
TMCM Software and Labs.sit
/
Software for TMCM 7_95
/
Files for Lab 10
/
Quadratic
< prev
next >
Wrap
Text File
|
1994-05-10
|
1KB
|
45 lines
{ This program computes and prints the solutions of the
equation A*x^2 + B*x + C = 0, where A, B, and C are
constants, as given by the quadratic formula. }
DECLARE A,B,C { constants in the equation }
DECLARE discriminant { calculated as B^2 - 4*A*C }
DECLARE root1, root2 { the two solutions of the equation }
A := 1 { Set values to be used for these constants in }
B := 1 { the equations; these numbers can be changed }
C := -1 { to find the solutions of any equation. }
PenUp { Adjust pen position so text will fit on screen }
moveTo(-8,5)
PenDown
{ describe output to the user }
DrawText("The solutions of A*x^2 + B*x + C = 0, where")
DrawText(" A = #A")
DrawText(" B = #B")
DrawText(" C = #C")
DrawText("are:")
{ calculate the solutions }
discriminant := B*B - 4*A*C
root1 := (-B - sqrt(discriminant)) / (2*A)
root2 := (-B + sqrt(discriminant)) / (2*A)
{ print the solutions }
DrawText(" #root1")
DrawText("and")
DrawText(" #root2")